package com.example.post.services.impl;
import com.example.post.mapper.RemarkMapper;
import com.example.post.model.Remark;
import com.example.post.services.RemarkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.List;
@Service
public class RemarkServiceImpl implements RemarkService {
    @Autowired
    RemarkMapper remarkMapper;
    @Override
    public List<Remark> getAllRemarks() {
        return remarkMapper.findAll();
    }
    @Override
    public void addRemark(String content, String observer, int blogId) {
        Remark remark = new Remark();
        remark.setObserver(observer);
        remark.setContent(content);
        remark.setCreateDate(LocalDateTime.now());
        remark.setBlogId(blogId);
        remarkMapper.addRemark(remark);
    }
    @Override
    public void deleteRemark(int id) {
        remarkMapper.deleteRemark(id);
    }
    @Override
    public List<Remark> getRemarkByBlogId(int blogId) {
        return remarkMapper.findRemarkByBlogId(blogId);
    }
    @Override
    public Remark getRemarkById(int id) {
        return remarkMapper.findRemarkById(id);
    }

    @Override
    public List<Remark> getRemarksByObserver(String observer) {
        return remarkMapper.findAllByObserver(observer);
    }


}
